﻿using System;
using System.ComponentModel;
using System.Windows;
using Wpf.Ui.Controls;
using Wpf.Ui.Controls.Interfaces;

namespace TVideo
{
    [ToolboxItem(true)]
    public class MyNavigationStore : NavigationStore
    {
        protected override void OnNavigationItemClicked(object sender, RoutedEventArgs e)
        {
            if (sender is not INavigationItem navigationItem)
                return;

            if (!string.IsNullOrEmpty(navigationItem.PageTag))
            {
                object? dataContext = DataContextFun?.Invoke(navigationItem);
                Navigate(navigationItem.PageTag, dataContext);
                return;
            }

            base.OnNavigationItemClicked(sender, e);
        }

        public Func<INavigationItem, object>? DataContextFun { get; set; }
    }
}
